﻿

Imports System.Data
Imports VSModel
Imports Cls_Common
Partial Class Control_MaSoThue_HoSoChoXuLy
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim _IsUser As Integer = Session("IsUser")
            BindToGrid(_IsUser)
        End If
    End Sub

    Protected Sub BindToGrid(ByVal _LoaiNguoiDung As Integer)


        Using _data As New VSEntities
            ' mot cua
            Dim curHuyenId As Integer = Session("HuyenId")
            If _LoaiNguoiDung = LoaiNguoiDung.Thue Then
                thue.Visible = True
                'tiêp nhân tu TCKH
                Dim _p = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueChoXuly Order By q.Created Descending Select q).ToList
                ltrSoluongCho.Text = _p.Count
                Dim p = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueChoXuly Order By q.Created Descending Select q).Take(20).ToList
                With rptTiepNhan
                    .DataSource = p
                    .DataBind()
                End With
                'Tiep Nhan
                Dim _k = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueDangXuly Order By q.Created Descending Select q).ToList
                ltrSoluongDangXyLy.Text = _k.Count
                Dim k = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueDangXuly Order By q.Created Descending Select q).Take(20).ToList
                With rptChoXuLy
                    .DataSource = k
                    .DataBind()
                End With

                'phòng tài chính kế hoạch duyệt chờ ký hoàn tất
                Dim _l = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueDuyet Order By q.Created Descending Select q).ToList
                ltrHoanTat.Text = _l.Count
                Dim l = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueDuyet Order By q.Created Descending Select q).Take(20).ToList
                With rptHoanTat
                    .DataSource = l
                    .DataBind()
                End With

                'hồ sơ bị trả về
                Dim _j = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueKhongDuyet Order By q.Created Descending Select q).ToList
                ltrTraVe.Text = _j.Count
                Dim j = (From q In _data.CertifiedHouseholds Where q.ProvinceId = curHuyenId And q.StatusId = TinhTrangHoSo.ThueKhongDuyet Order By q.Created Descending Select q).Take(20).ToList
                With rptTraVe
                    .DataSource = j
                    .DataBind()
                End With
            End If
        End Using
    End Sub
    Protected Sub rptTiepNhan_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptTiepNhan.ItemDataBound, rptChoXuLy.ItemDataBound, rptHoanTat.ItemDataBound, rptTraVe.ItemDataBound
        Dim row = CType(e.Item.DataItem, CertifiedHousehold)
        Dim hplTitle As HyperLink = e.Item.FindControl("hplTitle")
        Dim _NgayTao As String
        If Not row.Created Is Nothing Then
            _NgayTao = CType(row.Created, Date).ToString("dd/MM/yyyy")
        Else
            _NgayTao = ""
        End If
        hplTitle.Text = row.Ow_Name & " - " & "Ngày nhận: " & _NgayTao
        hplTitle.NavigateUrl = MainDomain & "Page/MaSoThue/Detail.aspx?Certifiedid=" & row.CertifiedID

    End Sub
End Class
